//
//  PersonalCenter.m
//  JiongTu
//
//  Created by Dupengfei on 16/4/8.
//  Copyright © 2016年 YSKJ. All rights reserved.
//

#import "PersonalCenter.h"
#import <AVUser.h>
#import <SVProgressHUD.h>
@implementation PersonalCenter
-(void)dataSaveInThisApp:(NSString *)name Gender:(NSString *)gender Tel:(NSString *)tel HeadImage:(NSString *)headImage
{
    
    NSString *pathUrl = [NSString stringWithFormat:@"%@/infomation%@.plist",NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject,[AVUser currentUser].objectId];
    //初始化文件管理者(文件管理器)
    NSFileManager *manager = [NSFileManager defaultManager];
    NSMutableArray *rootArray = nil;
    if ([manager fileExistsAtPath:pathUrl]) {
        // 存在
        // 从plist文件里拿数组
        rootArray = [NSMutableArray arrayWithContentsOfFile:pathUrl];
    }else{
        // 不存在
        // 创建新数据
        rootArray = [[NSMutableArray alloc] init];
    }
    // 讲用户信息打包成字典存入数组
    
    NSDictionary *infoDic = @{@"name":name,@"gender":gender,@"headImage":headImage,@"telphone":tel};
    
    [rootArray removeAllObjects];
    
    [rootArray addObject:infoDic];
    
    [rootArray writeToFile:pathUrl atomically:YES];
    
}
@end
